package com.codefish.codefishseckill.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codefish.codefishseckill.entity.Goods;
import com.codefish.codefishseckill.mapper.GoodsMapper;
import com.codefish.codefishseckill.service.GoodsService;
import com.codefish.codefishseckill.utils.PageUtils;
import com.codefish.codefishseckill.utils.model.PageInfo;
import com.codefish.codefishseckill.vo.GoodsVO;
import com.codefish.codefishseckill.vo.SecGoodsDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author codefish
 * @since 2022-07-07
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;


    @Override
    public List<GoodsVO> listAllGoodsInfo(PageInfo pageInfo) {
        pageInfo.setTotalCount(getAllGoodsCount());
        PageUtils.countPageSize(pageInfo);
        return goodsMapper.listAllGoodsInfo(pageInfo);
    }

    @Override
    public SecGoodsDetailVO getSecGoodsById(Long id) {
        return goodsMapper.getSecGoodsById(id);
    }

    @Override
    public Integer getAllGoodsCount() {
        return goodsMapper.getAllGoodsCount();
    }
}
